package a24_PolymorphicPractice;

/**
 * @Author quan
 * @Description 多态综合练习
 * @Date 2023/2/12 22:31
 */
public class TestDemo {
    public static void main(String[] args) {
        //写法1：创建对象并调用方法
        /*Person p = new Person("老王",30);
        Dog dog = new Dog(2,"黄");//狗 对象
        p.keepPet(dog,"骨头");//传入的对象是 狗

        Person p2 = new Person("老李",36);
        Cat cat = new Cat(3,"白");//创建 猫对象
        p2.keepPet(cat,"小鱼干");//传入的对象是 猫*/

        //方法2
        Person p = new Person("老王",30);
        Dog dog = new Dog(2,"黄");
        Cat cat = new Cat(3,"白");
        p.keepPet(dog,"骨头");
        p.keepPet(cat,"小鱼干");

    }
}
